#ifndef SIMPLEHP2DRECTANGULARALGORITHM_H
#define SIMPLEHP2DRECTANGULARALGORITHM_H

#include <profo/profo.h>
#include <profo/IAlgorithm.h>

using namespace profo;

/**
 * A simple implementation of the protein folding algorithm based on the H-P
 * model, in 2D rectangular grid.
 *
 * @author Dejan Lekic <dejan.lekic@kcl.ac.uk>
 */
class SimpleHP2DRectangularAlgorithm: public IAlgorithm {
  public:
  // CONSTRUCTORS
  SimpleHP2DRectangularAlgorithm(Protein& arg);
  // VIRTUAL methods that we implement in the .cpp file
  virtual GridType gridType();
  virtual bool is3D();
  virtual bool isRectangular();
  virtual void setProtein(Protein& arg);
  virtual double energy() const;
  virtual double energy(const Protein& arg) const;
  virtual void initProtein(const char* arg);
  virtual unsigned char getAvailableMoves(unsigned int arg);
  virtual void updateFreeMoves();
  virtual void move(unsigned char arg);
  virtual bool topologicalNeighbour(const AminoAcid& first, const AminoAcid& second) const;
  virtual bool checkValidity(unsigned int arg = 0) const;
  bool checkCorner(int argId, int& argX, int& argY);
  bool isFree(int argX, int argY);
  void calculateXY(unsigned int argId, unsigned char argMove, int& argX, int& argY);
#ifdef DEBUG
  static void unittest();
#endif

  private:
  // VARIABLES
  Protein& _proteinRef; ///< Object that holds all information about currently processed protein chain.
  std::string _authors; ///< Local copy of the authors list string
  std::string _description; ///< Local copy of the information about the algorithm
  bool _cornerFree; ///< We store information about C-location here - for convenience only.
  bool _moveDirectly; ///< A flag which indicates whether a certain move can be done without breaking validity.
}; // SimpleHP2DRectangularAlgorithm class

#endif // SIMPLEHP2DRECTANGULARALGORITHM_H
